gtkwindow: fix first allocation size
authorChristoph Reiter <creiter@src.gnome.org>
Fri, 1 Jan 2016 11:57:46 +0000 (12:57 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 3 Jan 2016 03:12:12 +0000 (22:12 -0500)
67ab00e01ec06d7b removed the fake configure code in gtk_window_show() and
replaced it with a simple gtk_widget_realize(). The initial allocation
code in realize() only allocates the natural size or the last requested
size which now no longer is set, resulting in a too small first allocation.

This builds a configure request to compute the allocation size instead
which includes default size, CSD etc..

This problem could be seen in case of a GtkPaned in a GtkWindow with a
default size set and the pane position set as well. The first allocation
would be the natural size of the GtkPaned which would clamp the pane
position if too larg. Only the second allocation would fill the parent
window using the now wrong pane position.

https://bugzilla.gnome.org/show_bug.cgi?id=759705

gtk/gtkwindow.c

index cb98bd6e006fcdd6222a72fb16425c3626c05d9a..ae8a81e1947cb02b706045aef35cadf53ea39ff7 100644 (file)
@@ -7137,15 +7137,15 @@ gtk_window_realize (GtkWidget *widget)
       allocation.width == 1 &&
       allocation.height == 1)
     {
-      gint w, h;
+      GdkRectangle request;
+      gint default_width, default_height;
+
+      gtk_window_compute_configure_request (window, &request, NULL, NULL);
 
       allocation.x = 0;
       allocation.y = 0;
-
-      gtk_window_guess_default_size (window, &allocation.width, &allocation.height);
-      gtk_window_get_remembered_size (window, &w, &h);
-      allocation.width = MAX (allocation.width, w);
-      allocation.height = MAX (allocation.height, h);
+      allocation.width = request.width;
+      allocation.height = request.height;
       gtk_widget_size_allocate (widget, &allocation);
 
       gtk_widget_queue_resize (widget);